﻿using OpenCvSharp;

using Xc.DataAccess.CodeReader.Properties;
using Xc.DataAccess.Core;

namespace Xc.DataAccess.CodeReader.Models.Filters
{
    /// <summary>
    /// 频谱相乘
    /// </summary>
    [Filter("频谱相乘", FilterType.Algorithm)]
    public class AlgorithmMulSpectrums : FilterBase
    {
        [InputParameter("待计算频谱")]
        public Mat Input2 { get; set; }=new Mat();
        /// <summary>
        /// 标志
        /// </summary>
        [InputParameter("转换标识符")]
        public DftFlags DftFlags { get; set; } = DftFlags.None;
        /// <summary>
        /// ConjB
        /// </summary>
        [InputParameter("ConjB")]
        public bool ConjB { get; set; }
        internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
        {
            Mat c = new Mat();
            Cv2.MulSpectrums(mat, Input2,c,DftFlags, ConjB);
            return ResultData<Mat>.Accept(TextResource.filter_action_complete, c);
        }
    }
    ///// <summary>
    ///// 亮度调节
    ///// </summary>
    //[Filter("亮度调节", FilterType.Algorithm)]
    //public class AlgorithmBrightness : FilterBase
    //{
    //    /// <summary>
    //    /// 亮度
    //    /// </summary>
    //    [InputParameter("亮度")]
    //    public double Brightness { get; set; } = 1;
    //    internal override ResultData<Mat> UseChannel(Mat mat, FilterBase[] filterInfos, FilterBase preFilterBase)
    //    {
    //        Modify(mat, Brightness);
    //        return ResultData<Mat>.Accept(TextResource.filter_action_complete, mat);
    //    }
    //    /// <summary>
    //    /// 修改亮度值和对比度
    //    /// </summary>
    //    /// <param name="mat"></param>
    //    /// <param name="brightness"></param>
    //    private void Modify(Mat mat,double brightness)
    //    {
    //        for (int y = 0; y < mat.Rows; y++)
    //        {
    //            for (int x = 0; x < mat.Cols; x++)
    //            {
    //                for (int c = 0; c < 3; c++)
    //                {
    //                    var f = mat.At<Vec3d>(y, x)[c];
    //                    var d = (f + brightness);
    //                    mat.At<Vec3d>(y, x)[c]= d;
    //                }
    //            }
    //        }
    //    }
    //}
}
